// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database();
// 云函数入口函数
exports.main = async(event, context) => {
  let ope=event.ope;
  let id = event.id;
  let status = event.status;
  let openid = event.userInfo.openId;
  if (ope == 'delete') {
    try {
      return await db.collection('tb_order_list').doc(id).remove()
    } catch (e) {
      console.log(e)
    }
  } else {
    let data = {
      _openid: openid,
      order_status: status
    }
    try {
      return await db.collection('tb_order_list').doc(id).update({
        data: data
      })
    } catch (e) {
      console.error(e)
    }
  }

}